Skip to content

Tests: Test only valid values for Datepicker defaultDate, min/maxDate #2143

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 30, 2023
Merged

Tests: Test only valid values for Datepicker defaultDate, min/maxDate #2143

merged 1 commit into from
Mar 30, 2023

Conversation

kendebacker
Copy link
Contributor

I was working on an issue with Datepicker (#1971) and when running some tests found that the tests are run with periods other than "y", "m", "w", and "d", which are the only valid periods listed in the docs https://api.jqueryui.com/datepicker/.

I think this is a particular problem for the tests with "m" and "d", as "M" and "D" refer to something very different in the Datepicker dateFormat. The latter refer to day/month names while the former to dates/month numbers.

Happy Holidays!

The docs say that valid periods when using string value and
period pairs as relative dates are "y", "m", "w", and "d"
https://api.jqueryui.com/datepicker/
@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Dec 25, 2022

CLA Signed

The committers listed above are authorized under a signed CLA.

  • ✅ login: kendebacker / name: Kenneth DeBacker (a8db321)

@mgol
Copy link
Member

mgol commented Dec 27, 2022

Thanks for the PR.

I think this is a particular problem for the tests with "m" and "d", as "M" and "D" refer to something very different in the Datepicker dateFormat. The latter refer to day/month names while the former to dates/month numbers.

In that case, how come all tests pass on main?

@kendebacker
Copy link
Contributor Author

kendebacker commented Dec 27, 2022

Hi,

Thanks for taking the time to respond to my PR.

All tests pass at the moment because currently both capital and lowercase time periods for relative dates are being accepted

Screen Shot 2022-12-27 at 1 09 38 PM

I am opting to change this to just lowercase time periods because that is the allowed input in the docs for relative dates

Screen Shot 2022-12-27 at 1 17 05 PM

which I believe was set that way because for date formats there is significant difference in meaning between upper and lower case

Screen Shot 2022-12-27 at 1 02 20 PM

I was planning to modify the code in 1588-1602 in another PR but thought I should wait to see if my thinking was correct.

@mgol
Copy link
Member

mgol commented Dec 27, 2022

Thanks for the info. At this stage of the project we're trying to avoid unnecessary breaking changes so I'm not sure we'd want to change the source here but I'll defer to @fnagel here who has way more experience with datepicker code.

@kendebacker
Copy link
Contributor Author

kendebacker commented Dec 27, 2022

Ah ok, thank you for explaining.

Apologies for straying outside the scope of this PR, but would a fix to #1971 be something worth pursuing? The issue is caused when the defaultDate, minDate, or maxDate setting option is given as a date string that is not in the specified dateFormat, the year is set 2028 and no error is thrown.

I was thinking that some code could be added to ensure that if the defaultDate, minDate, or maxDate is given as a date string that it is in the specified format, or else alert the user, as the user is not being alerted to the inconsistency in formatting.

Thanks again for taking the time to respond. I am looking to get experience contributing to open-source, but if if the project stage is not ideal for this, no worries

@mgol
Copy link
Member

mgol commented Dec 27, 2022

@kendebacker The issue sounds worth fixing, I think, but I'd still prefer to hear Felix's opinion first. 🙂 This is holiday time so let's wait a bit for his answer, perhaps in 2023.

@kendebacker
Copy link
Contributor Author

Ok sounds good, thanks @mgol , happy holidays!

@fnagel
Copy link
Member

fnagel commented Jan 15, 2023

Hi @kendebacker, hi @mgol! Happy new year!

I'm not that familiar with the Datepicker code as I only worked on the never published rewrite of it (Calendar and Datepicker 2.0).

Anyway, I don't see why we should test with other values than documented. So the current code of the PR seems valid to me. We might want to think about testing both (upper and lowercase) as both are supported. @mgol What do you think?

At this stage of the project we're trying to avoid unnecessary breaking changes so I'm not sure we'd want to change the source here

Yes. As long as changing the actual code doesn't fix a bug, we should not touch it IMO.

Regarding a fix for #1971 - sure, why not :-)

@fnagel fnagel requested a review from mgol January 15, 2023 21:36
@mgol mgol removed the Needs review label Mar 30, 2023
@mgol mgol added this to the 1.13.3 milestone Mar 30, 2023
@mgol mgol changed the title Tests: Datepicker defaultDate, minDate, and maxDate Tests: Test only valid values for Datepicker defaultDate, min/maxDate Mar 30, 2023
@mgol mgol merged commit f8990e6 into jquery:main Mar 30, 2023
@mgol
Copy link
Member

mgol commented Mar 30, 2023

@kendebacker sorry for the delay; landed now!

@kendebacker
Copy link
Contributor Author

Thanks @mgol !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

3 participants